// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import ComponentBase from "../../BASE/ComponentBase";
import GeZiManager from "../../Manager/GeZiManager";
import BAOmMAN from "./BAOmMAN";
import baoTX from "./baoTX";

const {ccclass, property} = cc._decorator;

@ccclass
export default class BAOMU extends ComponentBase {
@property(cc.Prefab)
    baoTX:cc.Prefab
    @property(cc.Label)
D11:cc.Label
@property(cc.Label)
end1:cc.Label
   Baomu(P1:number,D1:string,P2:number,end:string){

let p1=cc.instantiate(this.baoTX);
p1.setParent(this.node)
p1.getComponent(baoTX).get(P1)

this.D11.string=D1

let p2=cc.instantiate(this.baoTX);
p2.setParent(this.node)
p2.getComponent(baoTX).get(P2)

this.end1.string=end


   }
   playAnimation() {
    const duration = 2; // 动画持续时间
    const delay = 1; // 停留时间
    // 创建一个上升和放大的 Tween
    this.node.active=true
    const riseAndScale = cc.tween(this.node)
        .to(duration, { position: new cc.Vec3(this.node.position.x, this.node.position.y + 100, this.node.position.z), scale: 2 }) // 上升并放大
        .delay(delay) // 停留一会
        .to(duration, { opacity: 0, scale: 0 }) // 渐变消失并缩小
        .call(() => {
            GeZiManager.shanchu(this.node.parent.getComponent(BAOmMAN).BAOML,this.node)
            this.node.destroy(); // 动画结束后销毁节点
        });
    riseAndScale.start();
}

}
